package com.joshluisaac.dtos;

public class StringCompare {

	public static void main(String[] args) {
		
		String s1 = "hello";
		String s2 = "hello";
		String s3 = "hello";
		String s4 = new String("hello");
		String s5 = s4;
		
		System.out.println(s1.equals(s2)); //true
		System.out.println(s1==s2 ); //true
		System.out.println(s1==s3); //true
		System.out.println(s1==s4); //false
		System.out.println(s4==s5); //true
		s5 = "hey";
		System.out.println(s4==s5); //false
		System.out.println(s4.equals(s5)); //false
		
		Item item1 = new Item();
		Item item2 = new Item();
		
		Item item3 = item2;
		
		System.out.println(item1==item2); //false because they do not refer to the same object in memory
		System.out.println(item1.equals(item2)); //false contents are different
		System.out.println(item2==item3); //true because they refer to the same object in memory
		System.out.println(item2.equals(item3)); //true contents are same
		
		System.out.println(item1.hashCode()); //4540490
		System.out.println(item2.hashCode()); //9240774
		System.out.println(item3.hashCode()); //9240774


	}

}
